package com.fc.v2.service;

import java.util.List;
import java.util.Arrays;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import cn.hutool.core.util.StrUtil;
import com.fc.v2.common.base.BaseService;
import com.fc.v2.common.support.ConvertUtil;
import com.fc.v2.mapper.auto.ApplyTaskMapper;
import com.fc.v2.model.auto.ApplyTask;
import com.fc.v2.model.auto.ApplyTaskExample;
import com.fc.v2.model.custom.Tablepar;
import com.fc.v2.util.SnowflakeIdWorker;
import com.fc.v2.util.StringUtils;

/**
 * 参加者分工情况 ApplyTaskService
 * @Title: ApplyTaskService.java 
 * @Package com.fc.v2.service 
 * @author Archie_自动生成
 * @email ${email}
 * @date 2021-11-04 18:23:26  
 **/
@Service
public class ApplyTaskService implements BaseService<ApplyTask, ApplyTaskExample>{
	@Autowired
	private ApplyTaskMapper applyTaskMapper;
	
      	   	      	      	      	      	      	      	      	      	
	/**
	 * 分页查询
	 * @param pageNum
	 * @param pageSize
	 * @return
	 */
	 public PageInfo<ApplyTask> list(Tablepar tablepar,ApplyTask applyTask,String proId){
	        ApplyTaskExample testExample=new ApplyTaskExample();
			//搜索
			if(StrUtil.isNotEmpty(tablepar.getSearchText())) {//小窗体
	        	testExample.createCriteria().andLikeQuery2(tablepar.getSearchText());
	        }else {//大搜索
	        	testExample.createCriteria().andProjectIdEqualTo(proId);
	        }
			//表格排序
			//if(StrUtil.isNotEmpty(tablepar.getOrderByColumn())) {
	        //	testExample.setOrderByClause(StringUtils.toUnderScoreCase(tablepar.getOrderByColumn()) +" "+tablepar.getIsAsc());
	        //}else{
	        //	testExample.setOrderByClause("id ASC");
	        //}
	        PageHelper.startPage(tablepar.getPage(), tablepar.getLimit());
	        List<ApplyTask> list= applyTaskMapper.selectByExample(testExample);
	        PageInfo<ApplyTask> pageInfo = new PageInfo<ApplyTask>(list);
	        return  pageInfo;
	 }

	@Override
	public int deleteByPrimaryKey(String ids) {
				
			List<String> lista=ConvertUtil.toListStrArray(ids);
			ApplyTaskExample example=new ApplyTaskExample();
			example.createCriteria().andIdIn(lista);
			return applyTaskMapper.deleteByExample(example);
			
				
	}
	
	
	@Override
	public ApplyTask selectByPrimaryKey(String id) {
				
			return applyTaskMapper.selectByPrimaryKey(id);
				
	}

	
	@Override
	public int updateByPrimaryKeySelective(ApplyTask record) {
		return applyTaskMapper.updateByPrimaryKeySelective(record);
	}
	
	
	/**
	 * 添加
	 */
	@Override
	public int insertSelective(ApplyTask record) {
				
		//添加雪花主键id
		record.setId(SnowflakeIdWorker.getUUID());
			
				
		return applyTaskMapper.insertSelective(record);
	}

	/**
	 * 添加
	 */
	public int insertSelectiveAdd(ApplyTask record,String proId) {

		//添加雪花主键id
		record.setId(SnowflakeIdWorker.getUUID());
		//添加项目id
		record.setProjectId(proId);


		return applyTaskMapper.insertSelective(record);
	}
	
	
	@Override
	public int updateByExampleSelective(ApplyTask record, ApplyTaskExample example) {
		
		return applyTaskMapper.updateByExampleSelective(record, example);
	}

	
	@Override
	public int updateByExample(ApplyTask record, ApplyTaskExample example) {
		
		return applyTaskMapper.updateByExample(record, example);
	}

	@Override
	public List<ApplyTask> selectByExample(ApplyTaskExample example) {
		
		return applyTaskMapper.selectByExample(example);
	}

	
	@Override
	public long countByExample(ApplyTaskExample example) {
		
		return applyTaskMapper.countByExample(example);
	}

	
	@Override
	public int deleteByExample(ApplyTaskExample example) {
		
		return applyTaskMapper.deleteByExample(example);
	}
	
	/**
	 * 修改权限状态展示或者不展示
	 * @param applyTask
	 * @return
	 */
	public int updateVisible(ApplyTask applyTask) {
		return applyTaskMapper.updateByPrimaryKeySelective(applyTask);
	}


}
